home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 25.3 KB | 733 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FormView.cpp
- // Release Version: $ ODF 1 $
- //
- // Author: Laurent Delamare
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "Form.hpp"
-
- #ifndef FORMVIEW_H
- #include "FormView.h"
- #endif
-
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- #ifndef SCROLLED_H
- #include "ScrollEd.h"
- #endif
-
- // ----- Framework Layer -----
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWFRAME_H
- #include "FWFrame.h"
- #endif
-
- #ifndef FWLISTBX_H
- #include "FWListBx.h"
- #endif
-
- #ifndef FWBUTTON_H
- #include "FWButton.h"
- #endif
-
- #ifndef FWEDVIEW_H
- #include "FWEdView.h"
- #endif
-
- #ifndef FWPOPUP_H
- #include "FWPopup.h"
- #endif
-
- #ifndef FWCLUSTR_H
- #include "FWClustr.h"
- #endif
-
- #ifndef FWCONTXT_H
- #include "FWContxt.h"
- #endif
-
- #ifndef FWSCLBAR_H
- #include "FWSclBar.h"
- #endif
-
- #ifndef FWSTATIC_H
- #include "FWStatic.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWMENU_H
- #include "FWMenu.h"
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- #ifndef FWTXTSHP_H
- #include "FWTxtShp.h"
- #endif
-
- #ifndef FWPICSHP_H
- #include "FWPicShp.h"
- #endif
-
- #ifndef FWALERT_H
- #include "FWAlert.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_Commands_defined
- #include <CmdDefs.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODDispatcher_xh
- #include <Disptch.xh>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfform
- #endif
-
- FW_DEFINE_CLASS_M1(CFormView, FW_CSuperView)
-
- const FW_ClassTypeConstant LFormView = FW_TYPE_CONSTANT('F','r','m','v');
- FW_REGISTER_ARCHIVABLE_CLASS(LFormView, CFormView, CFormView::Create, FW_CView::Read, CFormView::Destroy, FW_CView::Write)
-
- //========================================================================================
- // CFormView
- //========================================================================================
- // Implementation of a content view drawing a background picture
-
- //----------------------------------------------------------------------------------------
- // CFormView::CFormView
- //----------------------------------------------------------------------------------------
-
- CFormView::CFormView(Environment* ev,
- FW_CSuperView* container,
- const FW_CRect& contentRect,
- const FW_CPoint& extent) :
- FW_CSuperView(ev, container, contentRect, kFormViewID, extent, FW_kXYScrolling),
- fFirstFormOn(true)
- {
- fRadioClusters[kModemSpeedCluster] = NULL;
- fRadioClusters[kDiscoverODFCluster] = NULL;
- fRadioClusters[kUsingOpenDocCluster] = NULL;
-
- // Adjust the bounds but don't redraw now
- CenterInFrame(ev, contentRect.Size(), FALSE);
- }
-
- //----------------------------------------------------------------------------------------
- // CFormView::CFormView
- //----------------------------------------------------------------------------------------
-
- CFormView::CFormView(Environment* ev) :
- FW_CSuperView(ev),
- fFirstFormOn(true)
- {
- fRadioClusters[kModemSpeedCluster] = NULL;
- fRadioClusters[kDiscoverODFCluster] = NULL;
- fRadioClusters[kUsingOpenDocCluster] = NULL;
-
- // Adjust the bounds but don't redraw now
- // CenterInFrame(ev, contentRect.Size(), FALSE); can do that here?
- }
-
- //----------------------------------------------------------------------------------------
- // CFormView::~CFormView
- //----------------------------------------------------------------------------------------
-
- CFormView::~CFormView()
- {
- // fRadioClusters are deleted when their last radio button is deleted
- }
-
-
- //----------------------------------------------------------------------------------------
- // CFormView::ActivateTarget
- //----------------------------------------------------------------------------------------
- // ActivateTarget is called the first time the frame gets the selection focus (because
- // a content view is always the frame's default target). We use this to change the target
- // to be the first text-edit field, i.e. to activate this field for keyboard events.
-
- void CFormView::ActivateTarget(Environment* ev, FW_Boolean tabSelection)
- {
- FW_CView* edview = FindViewById(ev, kFirstNameEdViewID);
-
- // Be sure that the edit view wants to be the target before doing it
- // (otherwise it would be activated even when it's invisible in the 2nd form)
-
- if (edview->WantsToBeTarget(ev))
- edview->BecomeTarget(ev, tabSelection);
- }
-
- //----------------------------------------------------------------------------------------
- // CFormView::PostCreateViewFromStream
- //----------------------------------------------------------------------------------------
- // PostCreateViewFromStream is called after subviews are created from resources.
- // Implement initializations for this view that can't be done from a stream.
-
- void CFormView::PostCreateViewFromStream(Environment* ev)
- {
- // ----- Link the frame to the list-box in order to respond to double-clicks
- // (standard controls are linked by defining their "receiver" resource field)
-
- // Note: this code could also reside in CFormFrame::PostCreateViewFromStream
- // if you prefer to do all PostCreate initializations in one place.
-
- CFormFrame* frame = (CFormFrame*)GetFrame(ev);
- FW_CListBox* listbox = (FW_CListBox*)FindViewById(ev, kPlatformListBoxID);
-
- frame->AddNotifier(listbox, FW_kListBoxDoubleClickedMsg);
-
- // ----- Add a behavior to the list-box to handle mouse clicks
- // (easier than subclassing FW_CListBox and defining a new resource type)
-
- CMouseUpBehavior* behavior = FW_NEW(CMouseUpBehavior, (ev, listbox));
- listbox->AdoptEventHandler(ev, behavior);
-
- // ----- Disable the "Remove" button by default
- FW_CButton* rmButton = (FW_CButton*) FindViewById(ev, kRemoveButtonID);
- rmButton->Disable(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CFormView::CreateOwnSubViews
- //----------------------------------------------------------------------------------------
- // Called from CFormFrame::CreateSubViews if compiled without using view resources
-
- void CFormView::CreateOwnSubViews(Environment* ev)
- {
- // NOTE: we left this code commented out because of compiling problem in Release mode
- // with CodeWarrior 8. Unless you have 60MB or so you'll get an "Out of memory"
- // error! It must be caused by the full-optimization flags used in Release mode.
- #if 0
- FW_Fixed fixed20 = FW_IntToFixed(20);
- FW_Fixed fixed40 = FW_IntToFixed(40);
- FW_CFont timesBold(FW_kTimes, FW_kBold, FW_IntToFixed(12));
- FW_CFont helvetica(FW_kHelvetica, FW_kPlain, FW_IntToFixed(12));
-
- FW_CRect viewRect; // working rect for creating the views
-
- // ----- Create edit fields in the content view
- viewRect.Set(FW_IntToFixed(290), FW_IntToFixed(90), FW_IntToFixed(450), FW_IntToFixed(107));
- FW_CPoint offset(FW_kFixed0, fixed20);
- for (int i = 0; i < 4; i++) {
- FW_CEditView* editView = FW_NEW(FW_CEditView, (ev, this, kFirstNameEdViewID+i, viewRect));
- editView->SetFont(ev, timesBold);
- viewRect += offset;
- }
-
- // ----- Create custom scrolling edit view with its scrollbar
- viewRect.Set(FW_IntToFixed(30), FW_IntToFixed(200), FW_IntToFixed(450), FW_IntToFixed(290));
- FW_CRect vertSbRect(viewRect.right - FW_kFixedPos1, viewRect.top,
- viewRect.right + FW_IntToFixed(15), viewRect.bottom);
- FW_CScrollBar* vertSB = FW_NEW(FW_CScrollBar, (ev, this, kEditVScrollBarID, vertSbRect));
- vertSB->SetBindings(ev, FW_kFixedBounds);
- CScrollEdit* scrollEdit = FW_NEW(CScrollEdit, (ev, this, kFirstNameEdViewID+4, viewRect, NULL, vertSB, FW_CString()));
-
- // ----- Create the "Subscribe" check box
- // Use null message (no receiver) and initial value of 1 to turn it on
- viewRect.Set(FW_IntToFixed(30), FW_IntToFixed(310), FW_IntToFixed(200), FW_IntToFixed(324));
- FW_CButton* check = FW_NEW(FW_CButton, (ev, this, kSubscribeCheckID, viewRect, FW_kCheckButton,
- FW_CString("Subscribe to ODFFlash"), timesBold, 0, 1));
-
- // ----- Create the Modem Speed radio butttons, their group box & the radio cluster
- viewRect.Set(FW_IntToFixed(30), FW_IntToFixed(360), FW_IntToFixed(220), FW_IntToFixed(440));
- FW_CGroupBox* modemSpeed = FW_NEW(FW_CGroupBox, (ev, this, viewRect,
- FW_CString(" Modem speed used"), timesBold));
-
- viewRect.Set(fixed40, FW_IntToFixed(380), FW_IntToFixed(210), FW_IntToFixed(396));
- FW_CButton* radio1 = FW_NEW(FW_CButton, (ev, this, k14400RadioID, viewRect,
- FW_kRadioButton, FW_CString("14.4 Kbps or lower")));
- viewRect.Offset(FW_kFixed0, fixed20);
- FW_CButton* radio2 = FW_NEW(FW_CButton, (ev, this, k28800RadioID, viewRect,
- FW_kRadioButton, FW_CString("28.8 Kbps to 256 Kbps")));
- viewRect.Offset(FW_kFixed0, fixed20);
- FW_CButton* radio3 = FW_NEW(FW_CButton, (ev, this, kFasterRadioID, viewRect,
- FW_kRadioButton, FW_CString("Faster than 256 Kbps")));
-
- fRadioClusters[kModemSpeedCluster] = FW_NEW(FW_CRadioCluster, (ev));
- fRadioClusters[kModemSpeedCluster]->AddRadio(ev, radio2);
- fRadioClusters[kModemSpeedCluster]->AddRadio(ev, radio1);
- fRadioClusters[kModemSpeedCluster]->AddRadio(ev, radio3);
-
- // ----- Create a list box (helvetica font, multiple selections, answer to double-clicks)
- viewRect.Set(FW_IntToFixed(250), FW_IntToFixed(362), FW_IntToFixed(400), FW_IntToFixed(440));
- FW_CListBox* listbox = FW_NEW(FW_CListBox, (ev, this, viewRect, kPlatformListBoxID, 10,
- true, helvetica, FW_kListBoxDoubleClickedMsg, false));
- listbox->SetDrawingMode(ev, FALSE);
- listbox->SetStringItem(ev, 1, FW_CString("Mac OS"));
- listbox->SetStringItem(ev, 2, FW_CString("OS/2 Warp"));
- listbox->SetStringItem(ev, 3, FW_CString("Windows 95"));
- listbox->SetStringItem(ev, 4, FW_CString("Windows NT"));
- listbox->SetStringItem(ev, 5, FW_CString("IBM AIX"));
- listbox->SetStringItem(ev, 6, FW_CString("Sun Sparc Solaris"));
- listbox->SetStringItem(ev, 7, FW_CString("Sun OS 4.1.x"));
- listbox->SetStringItem(ev, 8, FW_CString("HP /UX"));
- listbox->SetStringItem(ev, 9, FW_CString("Unix IRIX"));
- listbox->SetStringItem(ev, 10, FW_CString("Unix Linux"));
- listbox->SetDrawingMode(ev, TRUE);
-
- // ----- Create the Add/Remove buttons
- viewRect.Set(FW_IntToFixed(410), FW_IntToFixed(370), FW_IntToFixed(480), FW_IntToFixed(390));
- FW_CButton* addButton = FW_NEW(FW_CButton, (ev, this, kAddButtonID, viewRect,
- FW_kPushButton, FW_CString("Add")));
- viewRect.Set(FW_IntToFixed(410), FW_IntToFixed(400), FW_IntToFixed(480), FW_IntToFixed(420));
- FW_CButton* removeButton = FW_NEW(FW_CButton, (ev, this, kRemoveButtonID, viewRect,
- FW_kPushButton, FW_CString("Remove")));
- removeButton->Disable(ev);
-
- // ----- Create the "browsing time" popup
- viewRect.Set(FW_IntToFixed(30), FW_IntToFixed(477), FW_IntToFixed(230), FW_IntToFixed(497));
- FW_CPopupMenu* popup1 = FW_NEW(FW_CPopupMenu, (ev, this, kBrowseTimePopupID, viewRect,
- kBrowseTimeMenuResID, FW_CString()));
-
- // ----- Create the "online time" popup
- viewRect.Set(FW_IntToFixed(30), FW_IntToFixed(540), FW_IntToFixed(230), FW_IntToFixed(560));
- FW_CPopupMenu* popup2 = FW_NEW(FW_CPopupMenu, (ev, this, kOnlineTimePopupID, viewRect,
- kOnlineTimeMenuResID, FW_CString()));
-
- // ----- Create the "First Discover" radio butttons & their radio cluster
- viewRect.Set(FW_IntToFixed(30), FW_IntToFixed(580), FW_IntToFixed(350), FW_IntToFixed(700));
- FW_CGroupBox* discoverGroupB = FW_NEW(FW_CGroupBox, (ev, this, viewRect,
- FW_CString(" How did you discover ODFWired?"), timesBold));
-
- viewRect.Set(fixed40, FW_IntToFixed(600), FW_IntToFixed(300), FW_IntToFixed(616));
- FW_CButton* radio4 = FW_NEW(FW_CButton, (ev, this, kWorldMouthRadioID, viewRect,
- FW_kRadioButton, FW_CString("Word of mouth")));
- viewRect.Offset(FW_kFixed0, fixed20);
- FW_CButton* radio5 = FW_NEW(FW_CButton, (ev, this, kHyperLinkRadioID, viewRect,
- FW_kRadioButton, FW_CString("Hyperlink from another site:")));
- viewRect.Offset(FW_kFixed0, fixed20);
- FW_CButton* radio6 = FW_NEW(FW_CButton, (ev, this, kMacTechRadioID, viewRect,
- FW_kRadioButton, FW_CString("Ad in MacTech Magazine")));
- viewRect.Offset(FW_kFixed0, fixed20);
- FW_CButton* radio7 = FW_NEW(FW_CButton, (ev, this, kMagazineRadioID, viewRect,
- FW_kRadioButton, FW_CString("Other magazine, newspaper, radio")));
- viewRect.Offset(FW_kFixed0, fixed20);
- FW_CButton* radio8 = FW_NEW(FW_CButton, (ev, this, kOtherRadioID, viewRect,
- FW_kRadioButton, FW_CString("Other")));
- fRadioClusters[kDiscoverODFCluster] = FW_NEW(FW_CRadioCluster, (ev));
- fRadioClusters[kDiscoverODFCluster]->AddRadio(ev, radio4);
- fRadioClusters[kDiscoverODFCluster]->AddRadio(ev, radio5);
- fRadioClusters[kDiscoverODFCluster]->AddRadio(ev, radio6);
- fRadioClusters[kDiscoverODFCluster]->AddRadio(ev, radio7);
- fRadioClusters[kDiscoverODFCluster]->AddRadio(ev, radio8);
-
- // ----- Create the "using OpenDoc" radio butttons & their radio cluster
- viewRect.Set(fixed40, FW_IntToFixed(725), FW_IntToFixed(100), FW_IntToFixed(740));
- FW_CButton* radio9 = FW_NEW(FW_CButton, (ev, this, kYesRadioID, viewRect,
- FW_kRadioButton, FW_CString("Yes")));
- viewRect.Offset(FW_kFixed0, fixed20);
- FW_CButton* radio10 = FW_NEW(FW_CButton, (ev, this, kNoRadioID, viewRect,
- FW_kRadioButton, FW_CString("No")));
- fRadioClusters[kUsingOpenDocCluster] = FW_NEW(FW_CRadioCluster, (ev));
- fRadioClusters[kUsingOpenDocCluster]->AddRadio(ev, radio9);
- fRadioClusters[kUsingOpenDocCluster]->AddRadio(ev, radio10);
-
- // ----- Create the "Subscribe" button at the bottom of the content view
- FW_CString label("Join ODFWired!");
- viewRect.Set(FW_IntToFixed(300), FW_IntToFixed(750), FW_IntToFixed(450), FW_IntToFixed(775));
- FW_CButton* pushButton = FW_NEW(FW_CButton, (ev, this, kSubscribeButtonID, viewRect,
- FW_kPushButton, label));
-
- // ----- Link the frame to the controls it wants to respond to
- // (CFormFrame was defined as an FW_MReceiver and thus can respond to
- // notitications. We could also have decided to make CFormView the
- // receiver, it's a matter of choice)
- CFormFrame* frame = (CFormFrame*)GetFrame(ev);
-
- pushButton->LinkControlTo(ev, frame);
- addButton->LinkControlTo(ev, frame);
- removeButton->LinkControlTo(ev, frame);
- radio10->LinkControlTo(ev, frame);
- popup1->LinkControlTo(ev, frame);
-
- frame->AddNotifier(listbox, FW_kListBoxDoubleClickedMsg);
-
- // ----- Add a behavior to the list-box to handle mouse clicks
- // (easier than subclassing FW_CListBox and defining a new resource type)
- CMouseUpBehavior* behavior = FW_NEW(CMouseUpBehavior, (ev, listbox));
- listbox->AdoptEventHandler(ev, behavior);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // CFormView::Draw
- //----------------------------------------------------------------------------------------
-
- void CFormView::Draw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape)
- {
- // Set up drawing context for this view
- FW_CViewContext vc(ev, this, odFacet, invalidShape);
-
- // Erase with white first
- FW_CRect invalidRect;
- vc.GetClipRect(invalidRect);
- FW_CRectShape::RenderRect(vc, invalidRect, FW_kFill, FW_kWhiteEraseInk);
-
- CFormFrame* frame = (CFormFrame*)GetFrame(ev);
-
- if (fFirstFormOn)
- {
- // Draw a background picture (which was loaded in CFormPrt::InitPicture)
- // Note: this picture contains static text that could have been drawn using
- // Static Text view resources, as it was done in the 2nd form.
- frame->GetFormPart()->GetPictShape1()->Render(vc);
- }
- else
- {
- // Draw a background picture & the data entered by the user
- frame->GetFormPart()->GetPictShape2()->Render(vc);
- DrawUserData(ev, vc);
- }
-
- // SubViews of CFormView are drawn recursively after this point.
-
- // Mac Note: If you want to draw Controls with a non-white background color to match
- // the color of their parent view, you need either to define a color table for
- // the window (see CPwdDialogFrame::FacetAdded for an example) or define color tables
- // for individual controls. See "Inside Macintosh: Macintosh Toolbox Essentials".
- }
-
- //----------------------------------------------------------------------------------------
- // CFormView::CenterInFrame
- //----------------------------------------------------------------------------------------
-
- void CFormView::CenterInFrame(Environment* ev, FW_CPoint& contentSize, FW_Boolean redraw)
- {
- FW_CPoint viewSize(GetSize(ev));
- FW_CPoint viewExtent(GetExtent(ev));
- FW_CPoint viewLoc;
-
- FW_CRect contentRect(FW_kZeroPoint, contentSize);
- if (GetFrame(ev)->IsRoot(ev) == FALSE)
- {
- contentRect.Inset(FW_kFixedPos1);
- contentSize = contentRect.Size();
- }
-
- // Center the content view if it's smaller, or align it if it's bigger
- if (contentSize.x > viewExtent.x)
- {
- viewLoc.x = contentRect.left + FW_Half(contentSize.x - viewExtent.x);
- viewSize.x = viewExtent.x;
- }
- else
- {
- viewLoc.x = contentRect.left;
- viewSize.x = contentSize.x;
- }
-
- if (contentSize.y > viewExtent.y)
- {
- viewLoc.y = contentRect.top + FW_Half(contentSize.y - viewExtent.y);
- viewSize.y = viewExtent.y;
- }
- else
- {
- viewLoc.y = contentRect.top;
- viewSize.y = contentSize.y;
- }
-
- SetLocation(ev, viewLoc, redraw);
- SetSize(ev, viewSize, redraw);
- }
-
-
- //----------------------------------------------------------------------------------------
- // CFormView::AdjustToNewLayout
- //----------------------------------------------------------------------------------------
-
- void CFormView::AdjustToNewLayout(Environment *ev, const FW_CPoint& oldExtent,
- const FW_CPoint& newExtent, FW_Boolean redraw)
- {
- FW_UNUSED(oldExtent);
-
- // Adjust the new frame size to remove scroll-bar space
- FW_CPoint sbSize = FW_CScrollBar::GetDefaultScrollBarSize();
- FW_CPoint size = newExtent;
- size.x -= sbSize.x;
- size.y -= sbSize.y;
-
- CenterInFrame(ev, size, redraw);
-
- return;
- }
-
- //----------------------------------------------------------------------------------------
- // CFormView::DoMouseDown
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CFormView::DoMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent)
- {
- // Go back to the first form when clicking on the 2nd one
- if (!fFirstFormOn)
- SwitchForm(ev);
-
- return TRUE;
- }
-
- //----------------------------------------------------------------------------------------
- // CFormView::SwitchForm
- //----------------------------------------------------------------------------------------
-
- void CFormView::SwitchForm(Environment* ev)
- {
- if (fFirstFormOn)
- {
- fFirstFormOn = FALSE;
-
- // Hide all subviews but don't hide the form view itself
- SetVisible(ev, FALSE, TRUE);
- SetVisible(ev, TRUE, FALSE);
- }
- else
- {
- fFirstFormOn = TRUE;
-
- // Show all subviews
- SetVisible(ev, TRUE, TRUE);
-
- }
-
- // Force a redraw
- Invalidate(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CFormView::DrawUserData
- //----------------------------------------------------------------------------------------
-
- void CFormView::DrawUserData(Environment *ev, FW_CViewContext& vc)
- {
- FW_CPoint position;
- FW_Fixed vDelta = FW_IntToFixed(24);
- int i;
-
- FW_CString str;
- FW_CString32 yesStr("Yes");
- FW_CString32 noStr("No");
-
- position.x = FW_IntToFixed(200);
- position.y = FW_IntToFixed(90);
-
- // Edit views
- FW_CEditView* edview;
- for (i = 0; i < 4; i++)
- {
- edview = (FW_CEditView*)FindViewById(ev, kFirstNameEdViewID+i);
- str = edview->GetText(ev);
- FW_CTextShape::RenderText(vc, str, position, FW_kNormalFont);
- position.y += vDelta;
- }
-
- // Check box
- FW_CButton* button;
- button = (FW_CButton*)FindViewById(ev, kSubscribeCheckID);
- FW_CTextShape::RenderText(vc, button->GetState(ev) ? yesStr : noStr, position, FW_kNormalFont);
- position.y += vDelta;
-
- // Popups
- FW_CPopupMenu* popup1 = (FW_CPopupMenu*) FindViewById(ev, kBrowseTimePopupID);
- popup1->GetMenuString(ev, str);
- FW_CTextShape::RenderText(vc, str, position, FW_kNormalFont);
- position.y += vDelta;
-
- FW_CPopupMenu* popup2 = (FW_CPopupMenu*) FindViewById(ev, kOnlineTimePopupID);
- popup2->GetMenuString(ev, str);
- FW_CTextShape::RenderText(vc, str, position, FW_kNormalFont);
- position.y += vDelta;
-
- // Radio buttons
- CFormFrame* frame = (CFormFrame*) GetFrame(ev);
-
- for (i = 0; i < kNumRadioClusters; i++)
- {
- button = fRadioClusters[i]->GetButtonOn(ev);
- if (button)
- {
- button->GetLabel(ev, str);
- FW_CTextShape::RenderText(vc, str, position, FW_kNormalFont);
- position.y += vDelta;
- }
- }
-
- // List box
- FW_CListBox* list = (FW_CListBox*)FindViewById(ev, kPlatformListBoxID);
- const short maxPlaforms = 10;
- short platforms[maxPlaforms];
- short numSelected = list->GetSelectedItems(ev, maxPlaforms, platforms);
- if (numSelected > 0)
- {
- for (i = 0; i < numSelected; i++)
- {
- list->GetStringItem(ev, platforms[i], str);
- FW_CTextShape::RenderText(vc, str, position, FW_kNormalFont);
- position.y += FW_IntToFixed(16);
- }
- }
-
- }
-
- //----------------------------------------------------------------------------------------
- // CFormView::ResetData
- //----------------------------------------------------------------------------------------
-
- void CFormView::ResetData(Environment *ev)
- {
- // Erase the text of the 5 edit views
- FW_CEditView* edview;
- for (int i = 0; i < 4; i++)
- {
- edview = (FW_CEditView*)FindViewById(ev, kFirstNameEdViewID+i);
- edview->SetText(ev, FW_CString());
- }
-
- CScrollEdit* scrolledit = (CScrollEdit*)FindViewById(ev, kFirstNameEdViewID+4);
- scrolledit->SetText(ev, FW_CString());
- }
-
- //----------------------------------------------------------------------------------------
- // CFormView::Create
- //----------------------------------------------------------------------------------------
-
- void* CFormView::Create(FW_CReadableStream& stream, FW_ClassTypeConstant type)
- {
- FW_UNUSED(stream);
- FW_UNUSED(type);
- FW_SOMEnvironment ev;
- return new CFormView(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CFormView::Destroy
- //----------------------------------------------------------------------------------------
-
- void CFormView::Destroy(void* object, FW_ClassTypeConstant type)
- {
- FW_UNUSED(type);
- CFormView* self = (CFormView*) object;
- delete self;
- }
-
- //----------------------------------------------------------------------------------------
- // CFormView::Flatten
- //----------------------------------------------------------------------------------------
-
- void CFormView::Flatten(Environment* ev, FW_CWritableStream& archive) const
- {
- FW_CSuperView::Flatten(ev, archive);
-
- // [LSD] to complete
- }
-
- //----------------------------------------------------------------------------------------
- // CFormView::InitializeFromStream
- //----------------------------------------------------------------------------------------
- // This method is required to handle the custom resource fields added to the base type
-
- void CFormView::InitializeFromStream(Environment* ev, FW_CReadableStream& stream)
- {
- // Read-in the base resource first
- FW_CSuperView::InitializeFromStream(ev, stream);
-
- // Read-in the 3 radio-clusters defined in our RFormView type in "Views.fr"
- // and initialize our radio-clusters array for future use.
- for (int i = 0; i < kNumRadioClusters; i++)
- {
- FW_READ_DYNAMIC_OBJECT(stream, &fRadioClusters[i], FW_CRadioCluster);
- }
- }
-
-
- //========================================================================================
- // class CMouseUpBehavior
- //========================================================================================
- // Event handler class used to customize the mouse-click action in our list-box.
- // Having a behavior allows us to not have to subclass FW_CListBox (and also not to have
- // to define a new resource type in the .fr file)
-
- FW_DEFINE_AUTO(CMouseUpBehavior)
-
- //----------------------------------------------------------------------------------------
- // CMouseUpBehavior::CMouseUpBehavior
- //----------------------------------------------------------------------------------------
-
- CMouseUpBehavior::CMouseUpBehavior(Environment* ev, FW_CListBox* listBox) :
- FW_MEventHandler(ev, NULL, kNoPriority),
- fListBox(listBox)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CMouseUpBehavior::~CMouseUpBehavior
- //----------------------------------------------------------------------------------------
-
- CMouseUpBehavior::~CMouseUpBehavior()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CMouseUpBehavior::DoMouseUp
- //----------------------------------------------------------------------------------------
- // We use the mouse up event to check if the listbox has 1 or more selected items
- // and enable the "Delete" button in that case.
- // (In that case we cannot use a mouse down event behavior because it would be executed
- // before the listbox's mouse down handler, see FW_MEventHandler::DispatchMouseDown)
-
- FW_Boolean CMouseUpBehavior::DoMouseUp(Environment* ev, const FW_CMouseEvent& theMouseEvent)
- {
- // Enable the "Delete" button if there are 1 or more selected items
- if (fListBox->GetSelectedItem(ev) > 0)
- {
- FW_CSuperView* formView = fListBox->GetSuperView(ev);
- FW_CButton* rmButton = (FW_CButton*) formView->FindViewById(ev, kRemoveButtonID);
- FW_ASSERT(rmButton);
- rmButton->Enable(ev);
- }
-
- // let the list-box handle its mouse up event (although it doesn't matter here)
- return FALSE;
- }
-